package com.jsb.laundry.push;


import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.ServiceHelper;
import cn.jiguang.common.connection.NettyHttpClient;
import cn.jiguang.common.resp.ResponseWrapper;
import cn.jpush.api.push.model.PushPayload;
import java.net.URI;
import java.net.URISyntaxException;

import io.netty.handler.codec.http.HttpMethod;

public class Test {
    public static void main(String[] args) {
        ClientConfig clientConfig = ClientConfig.getInstance();
        String host = (String) clientConfig.get(ClientConfig.PUSH_HOST_NAME);
        NettyHttpClient client = new NettyHttpClient(ServiceHelper.getBasicAuthorization("84f97f51bef8ed21fc332af4", "3af06ff717cc0d66eab884f5"),
                null, clientConfig);
        try {
            URI uri = new URI(host + clientConfig.get(ClientConfig.PUSH_PATH));

            PushPayload payload = buildPushObject_all_alias_alert();
            client.sendRequest(HttpMethod.POST, payload.toString(), uri, new NettyHttpClient.BaseCallback() {
                @Override
                public void onSucceed(ResponseWrapper responseWrapper) {
                    System.out.println("Got result: " + responseWrapper.responseContent);
                }
            });
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }
    private static PushPayload buildPushObject_all_alias_alert() {
        // TODO: 构建具体的推送消息内容
        return PushPayload.alertAll("测试推送");
    }

}
